import Vue from 'vue'
import Vuex from 'vuex'
import user from './module/user' //  用户模块
import fileList from './module/fileList' //  文件列表模块
import sideMenu from './module/sideMenu' //  左侧菜单模块
import common from './module/common' //  公共模块
import uploadFile from './module/uploadFile' //  拖拽上传文件模块
import { allColumnList } from '@/libs/map.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  getters: {
    // 登录状态
    isLogin: (state) => state.user.isLogin,
    // 用户姓名
    username: (state) => state.user.userInfoObj.username,
    // 用户ID
    userId: (state) => state.user.userInfoObj.userId,
    // 表格显示列
    selectedColumnList: (state) =>
      state.fileList.selectedColumnList === null
        ? allColumnList
        : state.fileList.selectedColumnList.split(','),
    //用户的使用的容量
    storageValue: (state) => state.sideMenu.storageValue,
    //总的容量
    totalStorageValue: (state) => state.sideMenu.totalStorageValue,
    // 剩余存储空间给上传组件的BOX用
    remainderStorageValue: (state) =>
      state.sideMenu.totalStorageValue - state.sideMenu.storageValue
  },

  modules: {
    user,
    fileList,
    sideMenu,
    common,
    uploadFile
  }
})
